import { Encrypt,Decrypt} from "@/utils/CryptoJS";
const KEY = Encrypt('TOKEN_KEY') 
const store = sessionStorage
/**
 * 保存sessionStorage中的token
 * @param {*} token 
 */
export const saveToken = token =>{
   let date = Date.now()
   store.setItem(KEY,Encrypt({token,date}))
}
/**
 * 获取sessionStorage中的token
 */
export const getToken = () =>{
   let token = store.getItem(KEY) 
   if (token) {
      return  JSON.parse(Decrypt(token))
     }
      return token
}
/**
 * 移除sessionStorage中的token
 */
export const removeToken = () =>{
  store.removeItem(KEY)
}